package test;

import java.util.Arrays;
import java.util.Comparator;

public class StringsSort {
    public static void main(String[] args) {
        String strs[]=new String[4];
        strs[0]="yao";
        strs[1]="li";
        strs[2]="wu";
        strs[3]="wang";
        for (int i = 0; i < strs.length; i++) {
            System.out.println(strs[i]);
        }
        System.out.println("-------------");
        Arrays.sort(strs,new Comparator<String>(){
            @Override
            public int compare(String o1, String o2) {
                return o1.charAt(o1.length()-1)-o2.charAt(o2.length()-1);
            }
        });
        for (int i = 0; i < strs.length; i++) {
            System.out.println(strs[i]);
        }
    }
}
